package com.yonyou.pmclouds.basecom.bp.processor;

import com.yonyou.pmclouds.basecom.runtime.RuntimeEnvironment;
import com.yonyou.pmclouds.basecom.util.BeanHelper;
import com.yonyou.pmclouds.basecom.util.CommonFieldConst;
import org.springframework.stereotype.Component;

import java.util.Date;

@Component
public class AuditInfoInsertMultiProcessor<T> implements MultiProcessor<T> {
    @Override
    public void process(T[] vos, T[] origs) {
        String userId = RuntimeEnvironment.getLoginUserId();
        for (T vo : vos) {
            if (BeanHelper.getProperty(vo, CommonFieldConst.CREATOR) == null)
                BeanHelper.setProperty(vo, CommonFieldConst.CREATOR, userId);

            BeanHelper.setProperty(vo, CommonFieldConst.CREATIONTIME, new Date(System.currentTimeMillis()));
		}
    }
}
